<?php
namespace Home\Controller;

class EmailController extends CommonAction
{
    public function EmailController()
    {
        parent::__construct();
    }

    protected function _getNavigator($name, $action)
    {
        $navigator = array(
            array(
                'name' => '报表&邮件',
                'url' => '###'
            ),
            array(
                'name' => $name,
                'url' => $action
            )
        );
        return $navigator;
    }

    public function every_day_issue()
    {
        $date = $this->_getParam('date', date('Y-m-d'));
        $sectionId = $this->_getSectionId(__CLASS__, __FUNCTION__);
        $this->assign('navigator', $this->_getNavigator('每日任务', '/home/' . $sectionId));
        $this->assign('section', $sectionId);
        $this->assign('date', $date);
        $this->display();
    }

    public function daily_report()
    {
        $date = $this->_getParam('date', date('Y-m-d'));
        $sectionId = $this->_getSectionId(__CLASS__, __FUNCTION__);
        $this->assign('navigator', $this->_getNavigator('日报管理', '/home/' . $sectionId));
        $this->assign('section', $sectionId);
        $this->assign('date', $date);
        $this->display();
    }

    public function weekly_report()
    {
        $date = $this->_getParam('date', date('Y-m-d'));
        $sectionId = $this->_getSectionId(__CLASS__, __FUNCTION__);

        $weekMondayArray = array(6, 0, 1, 2, 3, 4, 5); // 获取星期一
        $weekSundayArray = array(0, 6, 5, 4, 3, 2, 1, 0); // 获取星期天
        $monday = date("Y.m.d",strtotime("-" . $weekMondayArray[date("w")] . " day"));
        $sunday = date("Y.m.d",strtotime("+" . $weekSundayArray[date("w")] . " day"));

        $this->assign('navigator', $this->_getNavigator('周报管理', '/home/' . $sectionId));
        $this->assign('section', $sectionId);
        $this->assign('date', $date);
        $this->assign('monday', $monday);
        $this->assign('sunday', $sunday);
        $this->display();
    }

    public function monthly_report()
    {
        $date = $this->_getParam('date', date('Y-m-d'));
        $sectionId = $this->_getSectionId(__CLASS__, __FUNCTION__);
        $this->assign('navigator', $this->_getNavigator('月报管理', '/home/' . $sectionId));
        $this->assign('section', $sectionId);
        $this->assign('date', $date);
        $this->display();
    }

    public function self_test_report()
    {
        $date = $this->_getParam('date', date('Y-m-d'));
        $sectionId = $this->_getSectionId(__CLASS__, __FUNCTION__);
        $this->assign('navigator', $this->_getNavigator('自测报告', '/home/' . $sectionId));
        $this->assign('section', $sectionId);
        $this->assign('date', $date);
        $this->display();
    }
}
